#include "StdAfx.h"
#include ".\regrecord.h"
#include <atlbase.h>

BOOL SetDynUserName( LPCTSTR lpszText )
{
	return WriteDnsProfit( L"username", lpszText );
}

CString GetDynUserName( void )
{
	return GetDnsProfit( L"username" );
}


BOOL SetDynPassword( LPCTSTR lpszText )
{
	return WriteDnsProfit( L"passwd", lpszText );
}

CString GetDynPassword( void )
{
	return GetDnsProfit( L"passwd" );
}

BOOL SetDynDomain( LPCTSTR lpszText )
{
	return WriteDnsProfit( L"domain", lpszText );
}

CString GetDynDomain( void )
{
	return GetDnsProfit( L"domain" );
}

BOOL WriteDnsProfit( LPCTSTR lpszKey , LPCTSTR lpszValue )
{
	int nResult = 0;
	
	CRegKey  reg;
	reg.Create( HKEY_LOCAL_MACHINE, L"SOFTWARE\\BnbtSoft\\" );
	nResult = reg.SetStringValue( lpszKey, lpszValue );		
	reg.Close();

	return nResult;
}

BOOL GetDnsProfit( LPCTSTR lpszKey , LPTSTR lpszValue, ULONG* pnChar )
{
	int nResult = 0;

	CRegKey  reg;
	reg.Create( HKEY_LOCAL_MACHINE, L"SOFTWARE\\BnbtSoft\\" );
	nResult = reg.QueryStringValue( lpszKey, lpszValue, pnChar );		
	reg.Close();

	return nResult;
}


CString  GetDnsProfit( LPCTSTR lpszKey )
{
	WCHAR szBuffer[512] = {0};
	ULONG  nchar = 512;

	int nResult = 0;

	CRegKey  reg;
	reg.Create( HKEY_LOCAL_MACHINE, L"SOFTWARE\\BnbtSoft\\" );
	nResult = reg.QueryStringValue( lpszKey, szBuffer, &nchar );		
	reg.Close();

	return CString( szBuffer );
}

